<?php

namespace app\admin\controller;

use app\admin\controller\Base;
use think\Controller;
use think\Request;

class Api extends Base
{

    public function upload(){
        // 获取表单上传文件
        $file = request()->file('file');
        $folder = input('param.folder');
        $dir =  'uploads/images/'. $folder;
        if (!is_dir($dir)) {
            mkdir($dir,0777,true);
        }
        $info = $file->move($dir);

        // {
        //     "code": 0
        //     ,"msg": ""
        //     ,"data": {
        //       "src": "http://cdn.layui.com/123.jpg"
        //     }
        //   } 

        if($info){
            // echo $info->getSaveName();
            $data=[
                'code'=>0,
                'msg'=>'',
                'data'=>['src'=>'/uploads/images/'.$info->getSaveName()]
            ];
               echo json_encode($data);
        }else{
            echo $file->getError();
        }
    }

    //奖品api




}
